
//
//  MKHomeViewModel.m
//  Weibo_OC
//
//  Created by mac on 16/1/16.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "MKHomeViewModel.h"
#import "MKNetworkTools.h"
#import "MKUserModelView.h"
#import "MKStatues.h"

@implementation MKHomeViewModel

+ (void)loadStatuesWithUrlString:(NSString *)urlString andWithSuccess:(void (^)(NSArray *))success {
    
    MKUserModelView *viewModel = [[MKUserModelView alloc] init];
    
//    viewModel.userAcc
    
    NSDictionary *parametersDic = @{@"access_token":viewModel.access_token};
    
    [[MKNetworkTools sharedNetworkTools] GET:urlString parameters:parametersDic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary * _Nullable responseObject) {
        
        NSArray *tempArray = responseObject[@"statuses"];
        NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:tempArray.count];
        
        for (NSDictionary *dict in tempArray) {
            MKStatues *statuesModel = [[MKStatues alloc] initWitchDict:dict];
            
            [mArray addObject:statuesModel];
        }
        
        success(mArray.copy);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       
        NSLog(@"%@",error);
    }];
}
@end
